home *** CD-ROM | disk | FTP | other *** search
- #ifdef DOCUMENTATION
- ******************************* DOCZ Header *********************************
- .MODULE haspriv
- .LIBRARY csub
- .TYPE function
- .APPLICATION system
- .SYSTEM vms
- .AUTHOR Software Toolz
- .LANGUAGE C
- .DESCRIPTION
- Test your process for priviledges
- .ARGUMENTS
- haspriv(privmask)
- int privmask; /* (r) the priviledge(s) to test */
- .NARRATIVE
- The Haspriv function tests the current process for one or more
- priviledges specified as a mask.
- .RETURNS
- Non-zero if the process has the specified privilege(s), 0 if not or on
- system call failure.
- .INCLUDES
- <prvdef.h>
- "csub.h"
- .EXAMPLE
- #include <prvdef.h>
-
- if (haspriv(PRV$M_TMPMBX))
- puts("TMPMBX");
- if (haspriv(PRV$M_NETMBX))
- puts("NETMBX");
- if (haspriv(PRV$M_SYSPRV |PRV$M_CMKRNL))
- puts("SYSPRV or CMKRNL");
- .NOTICE
- Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
-
- All rights reserved worldwide. This program may not be reproduced,
- transmitted, transcribed, stored in a retrieval system or translated in
- any human or computer language, in any form without the express written
- permission of Software Toolz, Inc.
- .ENDOC END DOCUMENTATION
- *****************************************************************************
- #endif
-
- #include <stdio.h>
- #include <ctype.h>
- #include <jpidef.h>
- #include <ssdef.h>
- #include <prvdef.h>
- #include "csub.h"
- #include "csubmac.h"
-
- /*****************************************************************************
- Getjobs
- *****************************************************************************/
- haspriv(privmask)
- int privmask; /* (r) the priviledge(s) to test */
- {
- int privs [2], /* priviledge mask */
- privlen,
- u;
- struct
- {
- short buffer_len,
- item_code;
- POINTER buff_addr,
- ret_addr;
- int terminator;
- } itemlist =
- {
- sizeof(privs),
- JPI$_CURPRIV,
- privs,
- &privlen,
- 0
- };
-
- if (VMSOK(SYS$GETJPIW(0,0,0,&itemlist,0,0,0)))
- {
- u = privs[0] & privmask;
- return (u);
- }
-
- return 0; /* return FALSE for system call failure */
-
- } /* end haspriv */
-